﻿<demos:DemoItem x:Class="DemoApplication.Demos.Controls.IconElement"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:bh="http://www.brokenhouse.co.uk/wpf"
                xmlns:diag="clr-namespace:System.Diagnostics;assembly=WindowsBase"
                xmlns:demos="clr-namespace:DemoApplication.Demos"
                Group="Controls" Label="Icon">
    

    <DockPanel Margin="1">
        <Grid DockPanel.Dock="Top" Margin="2" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition/>
                <RowDefinition/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <StackPanel Margin="0,0,0,5" Grid.ColumnSpan="3" >
                <TextBlock TextWrapping="Wrap" FontWeight="Bold" FontSize="14">
                    Icon
                </TextBlock>
                <TextBlock TextWrapping="Wrap" Margin="0,5,0,0">      
                    The role of this control is to present
                    an icon in the best way possible. This
                    example compares the different ways icons
                    can be displayed and how they are affected
                    by fractional positioning.
                </TextBlock>
                <TextBlock TextWrapping="Wrap" Margin="0,5,0,0">      
                    In order to deliberatly test the ability of this control 
                    the 2 of the 5 sizes do not correspond to the frames
                    contained in the icons.
                </TextBlock>
                <TextBlock TextWrapping="Wrap" Margin="0,5,0,0">    
                    In order to test how each of the rendering methods
                    are affected by sub-pixel rendering the sliders have been hooked up to the margin
                    surrounding each set of icons.
                </TextBlock>
            </StackPanel>
            <TextBlock Grid.Row="1" Grid.Column="0" Text="Horizontal" Margin="2" VerticalAlignment="Center"/>
            <Slider Grid.Row="1" Grid.Column="1" Minimum="0.0" Maximum="0.95" SmallChange="0.05" Value="{Binding HorizontalOffset}" Margin="2"/>
            <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding HorizontalOffset, StringFormat=({0:F2})}" VerticalAlignment="Center"/>
            <TextBlock Grid.Row="2" Grid.Column="0" Text="Vertical" Margin="2" VerticalAlignment="Center"/>
            <Slider Grid.Row="2" Grid.Column="1" Minimum="0.0" Maximum="0.95" SmallChange="0.05" Value="{Binding VerticalOffset}" Margin="2"/>
            <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding VerticalOffset, StringFormat=({0:F2})}" VerticalAlignment="Center"/>
        </Grid>

        <StackPanel  HorizontalAlignment="Center">
            <Border Margin="2,0,0,2"
                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 
                    BorderThickness="1" CornerRadius="2" SnapsToDevicePixels="True"
                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">

                <StackPanel DockPanel.Dock="Top" Margin="2"  Orientation="Horizontal">
                    <StackPanel Orientation="Horizontal" Margin="{Binding OffsetMargin}">
                        <bh:Icon Width="16" Height="16" SnapsToDevicePixels="True" Margin="3" VerticalAlignment="Center" Source="/DemoApplication;component/TestIcon.ico"/>
                        <bh:Icon Width="16" Height="16" SnapsToDevicePixels="True" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="20" Height="20" SnapsToDevicePixels="True" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="24" Height="24" SnapsToDevicePixels="True" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="28" Height="28" SnapsToDevicePixels="True" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="32" Height="32" SnapsToDevicePixels="True" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                    </StackPanel>
                    <StackPanel VerticalAlignment="Center" Margin="2">
                        <TextBlock Text="bh:Icon"/>
                        <TextBlock Text="SnapToDevicePixels=&quot;True&quot;" FontSize="9"/>
                    </StackPanel>
                </StackPanel>
            </Border>
            
            <Border Margin="2,2,0,2" DockPanel.Dock="Top"
                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 
                    BorderThickness="1" CornerRadius="2" SnapsToDevicePixels="True"
                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                <StackPanel Margin="2" Orientation="Horizontal">
                    <StackPanel Orientation="Horizontal" Margin="{Binding OffsetMargin}">
                        <bh:Icon Width="16" Height="16" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="/DemoApplication;component/TestIcon.ico" />
                        <bh:Icon Width="16" Height="16" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="20" Height="20" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="24" Height="24" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="28" Height="28" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                        <bh:Icon Width="32" Height="32" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{x:Static bh:TaskIcons.Information}"/>
                    </StackPanel>
                    <StackPanel VerticalAlignment="Center" Margin="2">
                        <TextBlock Text="bh:Icon"/>
                        <TextBlock Text="SnapToDevicePixels=&quot;False&quot;" FontSize="9"/>
                    </StackPanel>
                </StackPanel>
            </Border>

            <Border Margin="2,2,0,2" DockPanel.Dock="Top"
                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 
                    BorderThickness="1" CornerRadius="2" SnapsToDevicePixels="True"
                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                <StackPanel Margin="2" Orientation="Horizontal">
                    <StackPanel Orientation="Horizontal" Margin="{Binding OffsetMargin}">
                        <Image Width="16" Height="16" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="/DemoApplication;component/TestIcon.ico"/>
                        <Image Width="16" Height="16" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[0]}"/>
                        <Image Width="20" Height="20" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[1]}"/>
                        <Image Width="24" Height="24" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[1]}"/>
                        <Image Width="28" Height="28" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[1]}"/>
                        <Image Width="32" Height="32" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[1]}"/>
                    </StackPanel>
                    <StackPanel VerticalAlignment="Center" Margin="2">
                        <TextBlock Text="Image"/>
                        <TextBlock Text="RenderOptions.BitmapScalingMode=&quot;Unspecified&quot;" FontSize="9"/>
                    </StackPanel>
                </StackPanel>
            </Border>

            <Border Margin="2,2,0,2" DockPanel.Dock="Top"
                    BorderBrush="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" 
                    BorderThickness="1" CornerRadius="2" SnapsToDevicePixels="True"
                    Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                <StackPanel  Margin="2" Orientation="Horizontal">
                    <StackPanel Orientation="Horizontal" Margin="{Binding OffsetMargin}">
                        <Image Width="16" Height="16" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="/DemoApplication;component/TestIcon.ico" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                        <Image Width="16" Height="16" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[0]}" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                        <Image Width="20" Height="20" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[1]}" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                        <Image Width="24" Height="24" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[1]}" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                        <Image Width="28" Height="28" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[2]}" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                        <Image Width="32" Height="32" SnapsToDevicePixels="False" Margin="3" VerticalAlignment="Center" Source="{Binding Path=Icons[2]}" RenderOptions.BitmapScalingMode="NearestNeighbor"/>
                    </StackPanel>
                    <StackPanel VerticalAlignment="Center" Margin="2">
                        <TextBlock Text="Image"/>
                        <TextBlock Text="RenderOptions.BitmapScalingMode=&quot;NearestNeighbor&quot;" FontSize="9"/>
                    </StackPanel>
                </StackPanel>
            </Border>
        </StackPanel>
    </DockPanel>
</demos:DemoItem>
